package com.ctshk.rpc.user.service;

import com.ctshk.common.dto.Result;
import com.ctshk.rpc.user.dto.NumDTO;
import com.ctshk.rpc.user.dto.AppUserDTO;
import com.ctshk.rpc.user.req.*;

/**
 * @description User相关服务api
 * @author 谢诗宏
 * @date 2020/12/15
 */
public interface IUserService {

    Result<AppUserDTO> register(RegisterReq registerReq) throws Exception;

    Result smsCaptcha(String contactMobileAreaCode,String contactNumber,Integer type) throws Exception;

    Result resetPass(ForgetPwdReq forgetPwdReq) throws Exception;

    /**
     * 登录
     * @param u
     * @return
     */
    AppUserDTO login(AppUserDTO u);

    /**
     * 免密登录
     * @param userName
     * @return
     */
    AppUserDTO noPwdLogin(String userName);

    /**
     * 免密登录
     * @param userName
     * @return
     */
    AppUserDTO loginByPhone(String contactMobileAreaCode, String contactNumber);

    /**
     * 判断区号+手机号是否存在
     * @param
     * @param user
     * @return
     */
    boolean exists(AppUserDTO userDTO);

    /**
     * 查詢用戶
     * @param u
     * @return
     */
    AppUserDTO getUser(AppUserDTO u);

    /**
     * 根据id或者username查找用户-过滤删除标识
     * @param param
     * @param queryType
     * 		==1时id;==2时userAccount;==3时contactNumber,==4時email
     * @return
     */
    AppUserDTO loadUserByParam(Object param, Integer queryType);

    /**
     * 根据id或者username查找用户-不过滤删除标识
     * @param param
     * @param queryType
     * 		==1时id;==2时userAccount;==3时contactNumber,==4時email
     * @return
     */
    AppUserDTO loadUserInfo(Object param, Integer queryType);

    /**
     * 根据id查找缓存中的用户-不过滤删除标识
     * @param userId
     * @return
     */
    AppUserDTO queryCacheUser(long userId);

    /**
     * 将所有用户存入缓存中,每天更新一遍
     * @return
     */
    void insertCacheUser();

    /**
     * 重置密碼
     * @param id
     * @param password
     * @return
     */
    void resetPassword(long id, String password);

    /**
     * 创建C端用户
     * @param registerReq
     * @return
     */
    long addUser(RegisterReq registerReq,String password);

    Result saveUserInfo(SaveUserInfoReq req);

    Result updatePwd(UpdatePwdReq req);

    Result updatePhone(UpdatePhoneReq req) throws Exception;

    Result mail(String email, Long userId);

    Result updateEmail(UpdateEmailReq req);

    Result<AppUserDTO> registerStartVip(RegisterStartVipReq req);

    Result setEmail(SetEmailReq req);

    Result setMailSend(String email, Long userId);

    Result<NumDTO> getNum(Long userId);

    /**
     * 更新会员
     * @param req
     * @return
     */
    Result update(UpdateUserReq req);
}
